import React, { Component } from 'react';
import NoData from '../common/NoData';
import LinkTitle from '../common/LinkTitle';
export default class Message extends Component {
  constructor(props) {
    super(props);
  }
  componentDidMount() {
    this.props.getMessageList();
  }
  renderItem(item, index) {
    return (
      <li key={index} className="msgItem">
        <div className="logoWrapper">
          <img
            src={require('../../assets/img/common/logo-yidu.png')}
            className="logo"
          />
        </div>
        <div className="msgContent">
          <p className="fnormal">{item.content}</p>
          <div style={{ textAlign: 'right' }}>
            <time className="cbb f14">{item.createTime}</time>
          </div>
        </div>
        <div className="aHelper" onClick={() => this.props.deleteMsg(item)}>
          <span className="f20 c99">x</span>
        </div>
      </li>
    );
  }
  deleteMessage(item) {}
  render() {
    const { list } = this.props;
    return (
      <div className="userCWrapper message">
        <div className="ltWrapper">
          <LinkTitle title="我的消息" />
        </div>
        {list && list.length > 0 ? (
          <ul>{list.map((item, index) => this.renderItem(item, index))}</ul>
        ) : (
          <div style={{ marginTop: '4rem' }}>
            <NoData text="暂无消息" iconClass="iconfont icon-nodata-message" />
          </div>
        )}
      </div>
    );
  }
}
